﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace GameSnake
{
    public class GameEngine
    {
        private int _spead { get; set; }
        public GameEngine()
        {
            _spead = 250;
        }

        public event EventHandler Tick;

        public void Start()
        {
            for(;;)
            {
                Thread.Sleep(_spead);
                OnTick();

            }
        }
        public virtual void OnTick()
        {
            if (this.Tick != null)
                this.Tick(this, null);
        }
        public void ChangeSpead(int spead)
        {
            _spead = spead;
        }
    }
}
